/**
 * 用户模块的数据请求
 */
// 导入请求的方法
import request from '@/utils/request'

/**
 * 用户登录的请求方法
 * @param {*} data 
 */
export const login = data => {
    return request({
        method: 'post',
        url: '/v1_0/authorizations',
        data
    })
}

/**
 * 发送验证码的请求方法
 * @param {*} mobile 
 */
export const sendCode = mobile => request.get(`/v1_0/sms/codes/${mobile}`)

/**
 * 获取用户信息
 */
export const getUser = () => request({
        url: '/v1_0/user',

    })
    /**
     * 获取用户的频道列表
     */
export const getChannels = () => request.get('/v1_0/user/channels')

/**
 * 添加关注
 */
export const addFollow = userId => {
    return request({
        method: 'POST',
        url: '/v1_0/user/followings',
        data: {
            target: userId
        }
    })
}

/**
 * 取消关注
 */
export const deleteFollow = userId => {
    return request({
        method: 'DELETE',
        url: `/v1_0/user/followings/${userId}`
    })
}


// 获取用户资料
export const getUserProfile = () => request({
    url: '/v1_0/user/profile'
})

/**
 * 更新用户资料
 * @param {*} data 
 */
export const updateUserProfile = data => request({
    method: 'PATCH',
    url: '/v1_0/user/profile',
    data
})


/**
 * 更新用户头像
 */
export function updateUserPhoto(data) {
    return request({
        method: 'PATCH',
        url: '/v1_0/user/photo',
        data
    })
}